#ifndef __MENU_H__
#define __MENU_H__

#include "stdbool.h"
#include <Arduino.h>


#define MENU_DEBUG_LOG 1
// #ifdef MENU_DEBUG_LOG
//     menu_log("key up putdown");
// #endif


#define BASE_CHAR_TYPE_STRINGLENGTH 16
#define BASE_CHAR_TYPE_STRINGNUM 10
#define KEY_PUTDOWN HIGH       //按键按下电位

//按键定义
typedef enum
{
    KE_UP = 12,
    KEY_RIGHT = 13,
    KEY_LEFT = 14,
    KEY_DOWN = 27,
    KEY_NONE = 0,
} KEY_enum;

typedef enum
{
    char_type = 0,
    int_type,
    bool_type,
} BASE_TYPE_enum;

typedef enum
{
    main_menu_type = 10,
    layer_menu_type,
    base_menu_type,
} MENU_TYPE_enum;

//次级菜单
typedef struct layer_menu
{
    char *name;
    struct layer_menu *last;
    struct layer_menu *next;
    struct layer_menu *son;
} LAYER_menu;

//底层菜单
typedef struct base_cahr_menu
{
    int type;
    char selected[BASE_CHAR_TYPE_STRINGLENGTH];
    char optiona[BASE_CHAR_TYPE_STRINGNUM][BASE_CHAR_TYPE_STRINGLENGTH];
    LAYER_menu *father;
} BASE_cahr_menu;
typedef struct base_value_menu
{
    int type;
    int value;
    LAYER_menu *father;
} BASE_value_menu;
typedef struct base_bool_menu
{
    int type;
    bool selected;
    LAYER_menu *father;
} BASE_bool_menu;

//主菜单
typedef struct main_menu
{
    char *name;
    LAYER_menu *next;
} MAIN_menu;



void keyInit(int up,int down,int left , int right);     //按键初始化 传入按键GPIO号
KEY_enum keyScan();                                     //按键扫描


void menu_log(String str);


#endif

